import Vue from 'vue';
import Vuex from 'vuex';
import api from '@/fetch/url';

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		/**
		 * 是否需要强制登录
		 */
		forcedLogin: false,
		hasLogin: false,
		userName: "",
		headImgUrl:'',
		telPhone:0,
		isVIP:false,
		servicePhone:0,
		tabSelect:0,
		phoneData:"",
		oderInfo:null,//订单选择信息
		merchInfoForOrder:{},
		PeopleCheckList:[],
		orderFillInfo:null,
	},
	mutations: {
		loginStateInfo(state, userInfo) {
			state.userName = userInfo.nickName;
			state.headImgUrl = userInfo.headImgUrl ;
			state.isVIP = userInfo.member;
			state.telPhone = userInfo.phone;
			state.hasLogin = true;
		},
		logout(state) {
			state.userName = "";
			state.headImgUrl= "";
			state.hasLogin = false;
			state.isVIP = false;
		},
		getServicePhone(state){//获取客服电话
			api.getServicePhone({}).then(json=>{
				state.servicePhone = json;
			});
		},
		getPhoneType(state){
			uni.getSystemInfo({
				success: function(res) {
					state.phoneData = res;
				},	
			})
		},
		setTabSelect(state,index){
			state.tabSelect = index;
		},
		setCaleIndfo(state, order){
			state.oderInfo = order
		},
		setMerchInfoForOrder(state, info){
			state.merchInfoForOrder = info;
		},
		setPeopleCheckList(state, info){
			state.PeopleCheckList = info;
		},
		setOrderFillInfo(state, info){
			state.orderFillInfo = info;
		},
	}
})

export default store
